Skip to content

chore(tests): replace __eq__() with diff() for detailed test diagnostics#314

Merged
Molter73 merged 1 commit intomainfrom
mauro/tests/diff-on-failure
Feb 25, 2026
Merged

chore(tests): replace __eq__() with diff() for detailed test diagnostics#314
Molter73 merged 1 commit intomainfrom
mauro/tests/diff-on-failure

Conversation

@Molter73
Copy link
Contributor

@Molter73 Molter73 commented Feb 19, 2026

Description

When test assertions fail, the error messages now show exactly which fields differ between expected and actual events, rather than just displaying raw protobuf dumps. This significantly improves debugging efficiency by pinpointing the specific mismatches in process attributes, event types, paths, and event-specific fields.

Assisted-by: Claude Sonnet 4.5 noreply@anthropic.com

Checklist

  • Investigated and inspected CI test results
  • Updated documentation accordingly

Automated testing

  • Added unit tests
  • Added integration tests
  • Added regression tests

If any of these don't apply, please comment below.

Testing Performed

Manually triggered an error in the test and got the following output:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <server.FileActivityService object at 0x7fedd0d99400>, events = [<event.Event object at 0x7fedd0c446e0>], strict = True

    def _wait_events(self, events: list[Event], strict: bool):
        while self.is_running():
            msg = self.get_next()
            if msg is None:
                sleep(0.5)
                continue

            print(f'Got event: {msg}')

            # Check if msg matches any expected event
            diff = events[0].diff(msg)
            if diff is None:
                events.pop(0)
                if len(events) == 0:
                    return
            elif strict:
>               raise ValueError(json.dumps(diff, indent=4))
E               ValueError: {
E                   "file": {
E                       "expected": "/home/mmoltras/worktrees/fact/diff-on-failure/tests/fact-test-z9wg7j8k/create.txtother",
E                       "actual": "/home/mmoltras/worktrees/fact/diff-on-failure/tests/fact-test-z9wg7j8k/create.txt"
E                   }
E               }

@Molter73 Molter73 marked this pull request as ready for review February 19, 2026 16:43
@Molter73 Molter73 requested a review from a team as a code owner February 19, 2026 16:43
@Molter73 Molter73 enabled auto-merge (squash) February 19, 2026 17:09
Copy link
Contributor

@Stringy Stringy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! LGTM!

When test assertions fail, the error messages now show exactly which fields
differ between expected and actual events, rather than just displaying raw
protobuf dumps. This significantly improves debugging efficiency by pinpointing
the specific mismatches in process attributes, event types, paths, and
event-specific fields.

Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
@Molter73 Molter73 force-pushed the mauro/tests/diff-on-failure branch from 597a859 to c042b50 Compare February 25, 2026 14:39
@Molter73 Molter73 disabled auto-merge February 25, 2026 14:39
@Molter73 Molter73 requested a review from Stringy February 25, 2026 14:40
@Molter73 Molter73 enabled auto-merge (squash) February 25, 2026 14:40
Copy link
Contributor

@Stringy Stringy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor nits, but otherwise LGTM

event_field.old.path)
Event._diff_path(diff, 'old_host_path',
self.old_host_path, event_field.old.host_path)
return diff if diff else None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] this can be simplified a little

Suggested change
return diff if diff else None
return diff or None

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same below on 337)

@Molter73 Molter73 merged commit 2fc2abd into main Feb 25, 2026
24 checks passed
@Molter73 Molter73 deleted the mauro/tests/diff-on-failure branch February 25, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants